<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script crossorigin src="https://unpkg.com/react@17/umd/react.development.js"></script>
    <script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>
<!--    用于解析ES6-->
    <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
    <style>
        .red {
            color: red;
        }
    </style>
</head>
<!--ES6 -->
<!--列表渲染-->
<body>
    <div id="app"></div>
    <script type="text/babel">
        class Template extends React.Component {
            state = {
                list: [1,2,3,4,5]
            }
            render(){
                let arr = this.state.list
                const Lists =[]
                // 需要一个 唯一的 key
                arr.map((item,index) => {
                    let li = <li key={index}>{item}</li>
                    Lists.push(li)
                })
                return <div>
                    <ul>
                        {Lists}
                    </ul>
                </div>
            }
        }
        ReactDOM.render(<Template/>,document.getElementById('app'))
    </script>
</body>
</html>